package poker;
import java.util.Random;

public class Bot extends Player{

  private String playerName;
  private Random generator=new Random();

  /** KONSTRUKTOR. */
  Bot(String name){
    playerName=name;
  }

  /** ZWRACANIE NAZWY GRACZA. */
  String getName(){
    return("[" + playerName + "]");
  }

  /** ZWRACANIE WARTOSCI Z PRZEDZIALU [a,b] (LOSOWEJ). */
  int getValue(int a, int b){
    if(!(b>a)){return a;}
    else{return(generator.nextInt(b-a)+a);}
  }

  /** ZWRACANIE TABLICY KART DO WYMIANY (LOSOWYCH). */
  int[] exchangeCards(){
    int[] toExchange;
    int random1,random2,alreadyUsed;
    random1=generator.nextInt(5);
	if(random1==0){toExchange=new int[] {0};}
	else{
	  toExchange=new int[random1];
	  for(int i=0;i<random1;i++){
		do{
		  alreadyUsed=0;
	      random2=(generator.nextInt(5)+1);
		  for(int j=0;j<i;j++){if(toExchange[j]==random2) alreadyUsed=1;}
		}
		while(alreadyUsed==1);
		toExchange[i]=random2;
	  }
	}
	return toExchange;
  }
  
  /** ZWRACANIE NUMERU AKCJI W RUNDZIE LICYTACJI (LOSOWEJ). */
  /** OZNACZENIE: 1-Check, 2-Bet, 3-Raise, 4-Call, 5-Fold, 6-All-In. */
  int betAction(boolean noBet, boolean allIn, boolean canCall, boolean canRaise){
    int random;
    /** MOZNA ZAGRAC: Check, Bet, Fold, All-In. */
	/** SZANSA: 30%-Check, 60%-Bet, 5%-Fold, 5%-All-In. */
	if(noBet){
	random=generator.nextInt(100)+1;
	if(random<=30){return 1;}
	else if((random>30)&&(random<=90)){return 2;}
	else if((random>90)&&(random<=95)){return 5;}
	else if(random>95){return 6;}
	}
	/** MOZNA ZAGRAC: Raise, Call, Fold, All-In. */
	/** SZANSA: 25%-Raise, 50%-Call, 15%-Fold, 10%-All-In. */
	else if((!noBet)&&(!allIn)&&(canCall)&&(canRaise)){
	random=generator.nextInt(100)+1;
	if(random<=25){return 3;}
	else if((random>25)&&(random<=75)){return 4;}
	else if((random>75)&&(random<=90)){return 5;}
	else if(random>90){return 6;}
	}
	/** MOZNA ZAGRAC: Call, Fold, All-In. */
	/** SZANSA: 30%-Call, 40%-Fold, 30%-All-In. */
	else if((!noBet)&&(!allIn)&&(canCall)&&(!canRaise)){
	random=generator.nextInt(100)+1;
	if(random<=30){return 4;}
	else if((random>30)&&(random<=70)){return 5;}
	else if(random>70){return 6;}
	}
	/** MOZNA ZAGRAC: Fold, All-In. */
	/** SZANSA: 50%-Fold, 50%-All-In. */
	else if((!noBet)&&(!allIn)&&(!canCall)){
	random=generator.nextInt(100)+1;
	if(random<=50){return 5;}
	else if(random>50){return 6;}
	}
	/** MOZNA ZAGRAC: Fold, All-In. */
	/** SZANSA 50%-Fold, 50%-All-In. */
	else if(allIn){
	random=generator.nextInt(100)+1;
	if(random<=50){return 5;}
	else if(random>50){return 6;}
	}
    return 0;
  }

}